﻿namespace EAL.Converters
{
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Linq;
    using EAL.Models;

    class OrderStateLocalizationTypeConverter : TypeConverter
    {
        private static Dictionary<OrderState, String> _germanLookup = new Dictionary<OrderState, string>();


        static OrderStateLocalizationTypeConverter()
        {
            //only german version
            _germanLookup[OrderState.Created] = "Erstellt";
            _germanLookup[OrderState.Processing] = "In Bearbeitung";
            _germanLookup[OrderState.Payed] = "Bezahlt";
            _germanLookup[OrderState.Sent] = "An Kunde gesendet";
            _germanLookup[OrderState.Closed] = "Abgeschlossen";
        }

        public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType)
        {
            OrderState state = (OrderState)value;
            return _germanLookup[state];
        }

        public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value)
        {
            //only german version
            return _germanLookup.First(o => o.Value == (String)value);
        }
    }
}
